using System.Diagnostics;

namespace Xfinity.Physics
{
    /// <summary>
    /// A generic ODE to be solved.
    /// </summary>
    public abstract class Ode
    {
        /// <summary>
        /// Constructs a new ODE.
        /// </summary>
        /// <param name="numberOfEquations">The number of equations that must be solved.</param>
        protected Ode(int numberOfEquations)
        {
            dependantVariables = new double[numberOfEquations];
        }

        private double[] dependantVariables;

        /// <summary>
        /// The dependant variables.
        /// </summary>
        public double[] DependantVariables
        {
            [DebuggerStepThrough]
            get { return dependantVariables; }
        }

        private double time;

        /// <summary>
        /// The current time.
        /// </summary>
        public double Time
        {
            [DebuggerStepThrough]
            get { return time; }
            [DebuggerStepThrough]
            set { time = value; }
        }

        /// <summary>
        /// Evaluates the ODE.
        /// </summary>
        /// <param name="time">The current time.</param>
        /// <param name="dependantVariables">All the current dependant variables.</param>
        /// <param name="deltaDependantVariables">The delta of the dependant variables.</param>
        /// <param name="deltaTime">The delta of the time.</param>
        /// <param name="dependantVariableScale">The position between 0 and 1 of the RK evaluation.</param>
        /// <returns>The new dependant variables.</returns>
        public abstract double[] GetRightHandSide(double time, double[] dependantVariables,
                                                  double[] deltaDependantVariables, double deltaTime,
                                                  double dependantVariableScale);
    }
}